package top.yueyazhui.account.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.yueyazhui.account.service.AccountService;
import top.yueyazhui.common.bean.Response;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    AccountService accountService;

    @PostMapping("/deduct")
    public Response deductAccount(@RequestParam("userId") String userId, @RequestParam("money") Double money) {
        if (accountService.deductAccount(userId, money)) {
            return Response.success("扣款成功");
        }
        return Response.error("扣款失败");
    }
}
